********************************************************************************
**	PURPOSE: Put together the results of the calibration test including against null = 1, create T4
**							
**	INPUTS: testcal_ficoscore08_numloans_e1_df.xlsx
**			testcal_ficoscore08_numloans_e2_df.xlsx
**			testcal_ficoscore08_numloans_e3_df.xlsx
**			testcal_scoredf_numloans_e1_df.xlsx
**			testcal_scoredf_numloans_e2_df.xlsx
**			testcal_scoredf_numloans_e3_df.xlsx
**	
**	OUTPUTS: testcal_ficoscre08_numloans_null1.xlsx - Table 4
**			 testcal_scordf_numloans_null1.xlsx - Table 4 
**				
**  CREATED/MODIFIED BY:  Leah Kim, Hasan Ahamed
**
**	DATE CREATED: 7/26/2021
**
**	EDITED:	2/28/2023
********************************************************************************
clear all

loc dep ficoscore08 scoredf 
foreach d of local dep { 

	forval x = 1/3 {
	import delimited using "$outputtables//testcal_`d'_numloans_e`x'_df", clear
	format _all %9.3f	
	save "$adta//testcal_`d'_numloans_e`x'_df", replace
	}
	
	*Put all three waves together
	use "$adta//testcal_`d'_numloans_e1_df", clear
	append using "$adta//testcal_`d'_numloans_e2_df"
	append using "$adta//testcal_`d'_numloans_e3_df"

	gen null1_tval = abs(t1_s1_pred - 1) / t1_s1_se // recalculate t-statistics with null against 1 
	gen null1_meanforesttval = abs(t1_s1_meanforestpred - 1) / t1_s1_meanforestse // recalculate p-value with null against 1 

	gen null1_pval = ttail(t1_s1_n, null1_tval) * 2 // null hypothesis is greater or less than 0 
	gen null1_meanforestpval = ttail(t1_s1_n, null1_meanforesttval) * 2 // null hypothesis is greater or less than 0 
	
	export excel "$outputtables/testcal_`d'_numloans_null1.xlsx", replace firstrow(var) keepcellfmt

}

**EOF**


